home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0131_Save-Restore Graphics.pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  1KB  |  107 lines

  1.  
  2.  
  3. Procedure GetImage (X1,Y1,X2,Y2:Integer;P:Pointer); assembler;
  4. asm
  5.     mov  bx,320
  6.     push ds
  7.     les  di,P
  8.  
  9.     mov  ax,0A000h
  10.     mov  ds,ax
  11.     mov  ax,Y1
  12.     mov  dx,320
  13.     mul  dx
  14.     add  ax,X1
  15.     mov  si,ax
  16.  
  17.     mov  ax,X2
  18.     sub  ax,X1
  19.     inc  ax
  20.     mov  dx,ax
  21.     stosw
  22.  
  23.     mov  ax,Y2
  24.     sub  ax,Y1
  25.     inc  ax
  26.     stosw
  27.     mov  cx,ax
  28.  
  29.   @@1:
  30.     mov  cx,dx
  31.  
  32.     shr  cx,1
  33.     cld
  34.     rep  movsw
  35.  
  36.     test dx,1
  37.     jz         @@2
  38.     movsb
  39.   @@2:
  40.     add  si,bx
  41.     sub  si,dx
  42.  
  43.     dec  ax
  44.     jnz  @@1
  45.  
  46.     pop  ds
  47. end;
  48.  
  49. Procedure PutImage (X1,Y1:Integer;P:Pointer); assembler;
  50. asm
  51.     mov  bx,320
  52.     push ds
  53.     lds  si,P
  54.  
  55.     mov  ax,0A000h
  56.     mov  es,ax
  57.     mov  ax,Y1
  58.     mov  dx,320
  59.     mul  dx
  60.     add  ax,X1
  61.     mov  di,ax
  62.  
  63.     lodsw
  64.     mov  dx,ax
  65.  
  66.     lodsw
  67.  
  68.   @@1:
  69.     mov  cx,dx
  70.  
  71.     shr  cx,1
  72.     cld
  73.     rep  movsw
  74.  
  75.     test dx,1
  76.     jz         @@2
  77.     movsb
  78.   @@2:
  79.     add  di,bx
  80.     sub  di,dx
  81.  
  82.     dec  ax
  83.     jnz  @@1
  84.  
  85.     pop  ds
  86. end;
  87.  
  88. Procedure Init;
  89. begin
  90.   GetMem (Buf1,64000);
  91.   GetMem(Buf2,64000);
  92. end;
  93.  
  94. begin
  95.   init;
  96.   dographicstuff;
  97.  
  98.   GetImage( 0,0,319,199,Buf1);  {store page 1}
  99.  
  100.   domoregraphicstuff;
  101.  
  102.   GetImage( 0,0,319,199,Buf2);  {store page 2}
  103.  
  104.   PutImage (0,0, Buf1);  {restore page 1}
  105.  
  106. end.
  107.